package com.bizmerce.rnd.oms.decision.criterion;

import java.util.ArrayList;
import java.util.List;

import com.bizmerce.rnd.oms.decision.data.BillOfMaterials;
import com.bizmerce.rnd.oms.decision.data.RawMaterial;

/**
 * 완전생산기준 
 * 모든 원재료의 원산지가 한국산이면 인정
 * @author Gyeseon
 *
 */
public class WhollyObtained implements Criterion {
	
	private List<Criterion> relaxRuleList = null;

	public Boolean assign(BillOfMaterials bom) {
		
		boolean result = true;
		
		List<RawMaterial> rawMaterials = bom.getRawMaterials();
		for (RawMaterial material : rawMaterials) {
			//순수한 원산지 재료로 모든 공정이 1개국 내에서 수행되어야 한다.
			if(material.isIntraItem() && material.isInwardProcess()) {
				result &= true;
			} else{
				result &= false;
				break;
			}
		}
		return result;
	}

	public void addRelaxRule(Criterion relaxRule) {
		if(relaxRuleList == null) {
			relaxRuleList = new ArrayList<Criterion>();
		}
		relaxRuleList.add(relaxRule);
	}
}
